package ru.ifmo.ipimenov.ewf_svn.standalone.model.list;

import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.tmatesoft.svn.core.SVNURL;

import java.io.File;

import ru.ifmo.ipimenov.ewf_svn.standalone.model.db.Document;

/**
 * @author: Ilya Pimenov
 * Scartel Starlab company
 */
public class Item {
    /**
     * Logger for all purposes
     */
    private static Log log = LogFactory.getLog(Item.class);

    private String name;
    private SVNURL url;
    private File file;

    private int status = ACQUIRED;

    public static final int ACQUIRED = 0;
    public static final int DEPLOYED = 1;
    public static final int PROCESSING = 2;
    public static final int ADDED = 3;    

    private Document d;

    public String toString(){
        switch (status) {
            case ACQUIRED:
                return String.format("<html><span style=\"color: black; font-family: Times New Roman, Sans-Serif; font-size: 14pt;\">%s</html>", name);
            case PROCESSING:
                return String.format("<html><span style=\"color: blue; font-family: Times New Roman, Sans-Serif; font-size: 14pt;\"><i>%s</i>&nbsp;&#151; " +
                        "<span style=\"color: black; font-family: Times New Roman, Sans-Serif; font-size: 10pt;\">processing</span></html>", name);
            case DEPLOYED:
                return String.format("<html><span style=\"color: green; font-family: Times New Roman, Sans-Serif; font-size: 14pt;\"><i>%s</i>&nbsp;&#151; " +
                        "<span style=\"color: black; font-family: Times New Roman, Sans-Serif; font-size: 10pt;\">succesfully deployed</span></html>", name);
            case ADDED:
                return String.format("<html><span style=\"color: black; font-family: Times New Roman, Sans-Serif; font-size: 14pt;\"><i>%s</i>&nbsp;&#151; " +
                        "<span style=\"color: black; font-family: Times New Roman, Sans-Serif; font-size: 10pt;\">succesfully added</span></html>", name);
            default: return String.format("%s", name);
        }
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Item(String name) {
        this.name = name;
    }

    public Item(String name, SVNURL url, File file, Document d) {
        this.name = name;
        this.url = url;
        this.file = file;
        this.d = d;
    }

    public Document getD() {
        return d;
    }

    public void setD(Document d) {
        this.d = d;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public SVNURL getUrl() {
        return url;
    }

    public void setUrl(SVNURL url) {
        this.url = url;
    }

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }
}
